<html>
  <head>
    <title>Login</title>
    <script type="text/javascript">
    function validate() {
    	var re = /[^a-zA-Z]/; // A regular expression matches one occurrence of non-letter
    	var first = document.getElementById("first").value; // The first name
    	var middle = document.getElementById("middle").value;
    	var last = document.getElementById("last").value;
    	// All three names contain only letters and the first and last names should not be empty.
    	var valid = first.length > 0 && !re.test(first) && !re.test(middle) && last.length > 0 && !re.test(last);
        if(!valid) {
        	alert("Your name format is incorrect.");
        }
    	return valid;
    }
    </script>
  </head>
  <body>
    <form method=GET action=login.jsp onsubmit="return validate()">
      <table>
        <tr>
          <td>First Name</td>
          <td><input id="first" type=text name="firstname"></td>
        </tr>
        <tr>
          <td>Middle Initial</td>
          <td><input id="middle" type=text name="middlename"></td>
        </tr>
        <tr>
          <td>Last Name</td>
          <td><input id="last" type=text name="lastname"></td>
        </tr>
      </table>
      <input type=submit name=action value="Submit">
    </form>
  </body>
</html>
